Thread: Strategy Debugging, Entry Time, Max losers, profit target check

Results 1 to 5 of 5

  1. #1

    Default Strategy Debugging, Entry Time, Max losers, profit target check

    I am trying to verify my strategy is executing all requests. It is also not following my set trading time, it is trading all hours. Can someone please verify the below code looks correct. It is running and generating results, just not running at set time periods. I want to check that the MaxConsecLoser and profit targets are working correctly. I know you use a print command but I'm a little unsure on how to code it & interpret results. Thanks

    protected override void OnBarUpdate()
    {
    if ((ToTime(Time[0]) >= ToTime(8, 30, 0))||(ToTime(Time[0]) < ToTime(14, 45, 0))
    && (Performance.AllTrades.TradesPerformance.Currency. CumProfit - priorTradesCumProfit >= PrftGoal)
    && (Position.MarketPosition != MarketPosition.Flat)
    && (Performance.AllTrades.TradesPerformance.MaxConsec Loser < MaxLosers)
    )
    {
    priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.C umProfit - priorTradesCumProfit;
    }
    // At the start of a new session
    if (Bars.FirstBarOfSession)
    {
    // Store the strategy's prior cumulated realized profit and number of trades
    priorTradesCount = Performance.AllTrades.Count;
    priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.C umProfit;
  2. #2

    Default

    Hello TOOLMachine462,

    While I have not yet tested your code, I noticed your first condition block contains ambiguous logic. Where you have
  3. #3

    Default

    Please let us know if the above does not end up doing what you would like, or if you have any other questions we can help with.
  4. #4

    Default

    Your time filter:
    Code:
    (ToTime(Time[0]) >= ToTime(8, 30, 0))||(ToTime(Time[0]) < ToTime(14, 45, 0))
    is always true. It looks like you are looking for "&&" not "||" as your logic operator?
  5. #5

    Default

    Thanks for the catch.

    However, I think we're both wrong. If the OP just uses && instead of ||, their condition will do the exact opposite of what I think this user wants, as it will only exit out of their strategy between 8:30 and 14:15, and NOT before or after hours.

    So that block should be

    ! (ToTime(Time[0]) >= ToTime(8, 30, 0)) && (ToTime(Time[0]) < ToTime(14, 45, 0))

    In short I think this needs to be a NAND

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts