Syntax error in assignment – Help needed

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #77858 quote
    rdcarvajal
    Participant
    New

    Hello:

    I am seeing the following error when i try to run a back-test on the code below.

    “Syntax error in assignment”

    I can’t figure out what’s wrong. Can any of you find out where is the mistake?

    Thanks.

     
    DEFPARAM CumulateOrders = false
    Reinvest=1
    if reinvest then
    Capital = 10000
    Risk = 1//0.1//in % pr position
    StopLoss = 48
    REM Calculate contracts
    equity = Capital + StrategyProfit
    maxrisk = round(equity*(Risk/100))
    MAXpositionsize=5000
    MINpositionsize=1
    Positionsize= MAX(MINpositionsize,MIN(MAXpositionsize,abs(round((maxrisk/StopLoss)))))//*Pointsize))))
    else
    Positionsize=1
    StopLoss = 48
    Endif
     
    ///BILL WILLIAM FRACTAL INDICATOR
    //CP=PERIOD
    CP=113
    if close[cp] >= highest[2*cp+1](close) then
    LH = 1
    else
    LH=0
    endif
    if close[cp] <= lowest[2*cp+1](close)  then
    LL= -1
    else
    LL=0
    endif
    if LH=1 then
    HIL = close[cp]
    endif
    if LL  = -1 then
    LOL=close[cp]
    endif
    // RETURN, HIL COLOURED(0,200,0) AS "BREAKOUT LEVEL LONG",HIL COLOURED(200,0,0) AS "BREAKOUT LEVEL SHORT"
     
     
    //LONG and SHORT CONDITIONS
    //Positionsize=1
    if (time >=100000 and time < 230000) then
    C1 = (close CROSSES OVER HIL)
    D1 = (close CROSSES UNDER LOL)
    IF c1 and not shortonmarket THEN
    BUY positionsize CONTRACT AT MARKET
    InitialStopLong = Low
    ENDIF
    IF D1 and not longonmarket THEN
    SELLSHORT positionsize CONTRACT AT MARKET
    InitialStopShort = High
    ENDIF
    ENDIF
    
    
    //TRAILING STOP
    TGL =5
    TGS=5
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    PREZZOUSCITA = 0
    ENDIF
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close)
    if MAXPRICE-tradeprice(1)>=TGL*pointsize then
    PREZZOUSCITA = MAXPRICE-TGL*pointsize
    ENDIF
    ENDIF
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    if tradeprice(1)-MINPRICE>=TGS*pointsize then
    PREZZOUSCITA = MINPRICE+TGS*pointsize
    ENDIF
    ENDIF
    if onmarket and PREZZOUSCITA>0 then
    EXITSHORT AT PREZZOUSCITA STOP
    SELL AT PREZZOUSCITA STOP
    ENDIF
     
    // DONCHIAN STOP
    DC=20
    e= Highest[DC](high)
    f=Lowest[DC](low)
    if longonmarket  then
    laststop = f[1]
    endif
    if shortonmarket  then
    laststop = e[1]
    endif
    if longonmarket AND initialStopLong>laststop then
    Sell at InitialStopLong
    ELSE
    sell at laststop stop
    Endif
    If shortonmarket AND initialStopShort<laststop then
    Exitshort at InitialStopShort
    ELSE
    exitshort at laststop stop
    Endif
     
    set target profit 30
    set stop loss stoploss*pointsize
    

     

    #77859 quote
    GraHal
    Participant
    Master

    Line 93 and Line 98 need keyword ‘stop’ at the end??

    What Instrument and TF is the code set to run on please? 

    #77860 quote
    Nicolas
    Keymaster
    Master
    Don’t know why but there where wrong formatted copy/paste code and some syntax errors too, here is the fixed code:
    DEFPARAM CumulateOrders = false
    Reinvest=1
    if reinvest then
    Capital = 10000
    Risk = 1//0.1//in % pr position
    StopLoss = 48
    REM Calculate contracts
    equity = Capital + StrategyProfit
    maxrisk = round(equity*(Risk/100))
    MAXpositionsize=5000
    MINpositionsize=1
    Positionsize= MAX(MINpositionsize,MIN(MAXpositionsize,abs(round((maxrisk/StopLoss)))))//*Pointsize))))
    else
    Positionsize=1
    StopLoss = 48
    Endif
    
    ///BILL WILLIAM FRACTAL INDICATOR
    //CP=PERIOD
    CP=113
    if close[cp] >= highest[2*cp+1](close) then
    LH = 1
    else
    LH=0
    endif
    if close[cp] <= lowest[2*cp+1](close) then
    LL= -1
    else
    LL=0
    endif
    if LH=1 then
    HIL = close[cp]
    endif
    if LL= -1 then
    LOL=close[cp]
    endif
    // RETURN, HIL COLOURED(0,200,0) AS "BREAKOUT LEVEL LONG",HIL COLOURED(200,0,0) AS "BREAKOUT LEVEL SHORT"
    
    //LONG and SHORT CONDITIONS
    //Positionsize=1
    if (time >=100000 and time < 230000) then
    C1 = (close CROSSES OVER HIL)
    D1 = (close CROSSES UNDER LOL)
    IF c1 and not shortonmarket THEN
    BUY positionsize CONTRACT AT MARKET
    InitialStopLong = Low
    ENDIF
    IF D1 and not longonmarket THEN
    SELLSHORT positionsize CONTRACT AT MARKET
    InitialStopShort = High
    ENDIF
    ENDIF
    
    
    //TRAILING STOP
    TGL =5
    TGS=5
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    PREZZOUSCITA = 0
    ENDIF
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close)
    if MAXPRICE-tradeprice(1)>=TGL*pointsize then
    PREZZOUSCITA = MAXPRICE-TGL*pointsize
    ENDIF
    ENDIF
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    if tradeprice(1)-MINPRICE>=TGS*pointsize then
    PREZZOUSCITA = MINPRICE+TGS*pointsize
    ENDIF
    ENDIF
    if onmarket and PREZZOUSCITA>0 then
    EXITSHORT AT PREZZOUSCITA STOP
    SELL AT PREZZOUSCITA STOP
    ENDIF
    
    // DONCHIAN STOP
    DC=20
    e= Highest[DC](high)
    f=Lowest[DC](low)
    if longonmarket then
    laststop = f[1]
    endif
    if shortonmarket then
    laststop = e[1]
    endif
    if longonmarket AND initialStopLong>laststop then
    Sell at InitialStopLong stop
    ELSE
    sell at laststop stop
    Endif
    If shortonmarket AND initialStopShort<laststop then
    Exitshort at InitialStopShort stop
    ELSE
    exitshort at laststop stop
    Endif
    
    set target profit 30
    set stop loss stoploss*pointsize
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Syntax error in assignment – Help needed


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rdcarvajal @rdcarvajal Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Nicolas
7 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/09/2018
Status: Active
Attachments: No files
Logo Logo
Loading...