Strategy Profit not working in realtime

Forums ProRealTime English forum ProOrder support Strategy Profit not working in realtime

Viewing 10 posts - 1 through 10 (of 10 total)
  • #194829

    Hi I have the code below to stop opening new positions when one of the positions in the day closed with loss more than 200 or profit more than 350.

    It works perfectly in the proback test but when I execute it in IG in real market it still open position even after the loss happens. I am not sure what I am missing here?

     

    Please note the code works when I am in positive and will not open new position after hitting 350. Could it be because of negative number in the strategy profit somehow mess up the formula?

    This is my code:

     

    If time=100000 then

    MyProfit=STRATEGYPROFIT[0]

    endif

    if time>100000 and time <150000 and countoflongshares<90 and range[1]<14 and countofshortshares<90 and Strategyprofit[0]>MyProfit-200 and Strategyprofit[0]<MyProfit+350

     

    then  ……..

     

    #194830

    I am starting my code with : once myprofit=0 at the begining, could this be the reason?

    #194831

    You have to use a variable as a signal that you don’t want to trade any longer that day (I will use TradeOK, setting to 1 at the beginning of each day), as soon as your strategy detects a loss of X, it will set TradedOK to 0. Your strategy will have to use TradeOK to tell whether trading or not:

    #194835

    thanks, so why my code worked in the probacktest but not in reallife?

    #194838

    I have no idea without testing the complete code used.

     

    #194840

    since I want to look at the whole day performance , should I change your code to the below to not only check with the last bar but for the whole day from morning:

     

    ONCE TradeOK = 1
    ONCE MyLimit = 200
    IF time = 100000 THEN
    TradeOK = 1
    Myprofit=strategyprofit
    ENDIF
    IF (Myprofit- strategyprofit) >= MyLimit THEN
    TradeOK = 0
    ENDIF

    #194845

    Also will this still work if your strategy starts in negative. What I noticed is that if my total strategy profit is positive then next day the code works and when I have lost it stops but when the strategy was already in negative from last day the code somehow can’t calculate the negative minus negative and stop working

    #194848

    Try replacing line 6 with:

     

    #194855

    Thanks, but I need the strategy profit be calculated for the total of positions from 10:00 am. In your code if one of the positions closes in negative the strategy will stop because it will always compare the current bar with the last bar not the total strategyprofit from 10:00 am

    #194861

    You code above works fine for me. Why don’t you think it’s correct?

    Try appending some GRAPH instructions to monitor data candle by candle:

    1 user thanked author for this post.
Viewing 10 posts - 1 through 10 (of 10 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login