Roberto HELP, profit e q.tà contratti

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #202027 quote
    MaoRai54MaoRai54
    Participant
    Master

    Roberto,

    sto impazzendo per impostare uno snippet che in funzione del profitto, aumentato o diminuito, suddiviso tra long e short, aumenta o diminuisce la quantità dei contratti.

    Tu, qui su forum, mi avevi messo quello che allego qui sotto. Ma secondo me non aumenta/diminuisce le q.tà nel modo giusto.

    Versione ROBERTO:

    //////////////////////// Q.TY CONTRACTS

    MS=1

    ONCE LongProfit  = 0

    ONCE ShortProfit = 0

    IF StrategyProfit <> StrategyProfit[1] AND BarIndex > 0 THEN

    Profitto = StrategyProfit – StrategyProfit[1]

    IF LongOnMarket[1] THEN

    LongProfit  = LongProfit  + Profitto

    ELSIF ShortOnMarket[1] THEN

    ShortProfit = ShortProfit + Profitto

    ELSE

    p1 = 1

    p2 = 2

    IF OnMarket THEN

    p1 = 2

    p2 = 3

    ENDIF

    IF TradePrice(p1) > TradePrice(p2) THEN

    IF Profitto > 0 THEN

    LongProfit  = LongProfit  + Profitto

    ELSE

    ShortProfit = ShortProfit + Profitto

    ENDIF

    ELSIF TradePrice(p1) < TradePrice(p2) THEN

    IF Profitto < 0 THEN

    LongProfit  = LongProfit  + Profitto

    ELSE

    ShortProfit = ShortProfit + Profitto

    ENDIF

    ELSE

    LongProfit  = LongProfit  + (Profitto / 2)

    ShortProfit = ShortProfit + (Profitto / 2)

    ENDIF

    ENDIF

    ENDIF

     

    /////////////////// for LONG trades

    once LotSizeL = 1

    Once MinSizeL = 1      //minimum size required

    Once LotSizeL = MinSizeL  //starting size (can be bigger than minimum)

    Once LotStepL = LL200 //250      //increase/decrease this money step

    LotSizeL = max(MinSizeL,round((MinSizeL/MS),1) + (MinSizeL * round((LongProfit / LotStepL),1)))

    if LotSizeL>MU then

    LotSizeL=MU-MMUU   //MU e MMUU metterli con decimale 0.5

    endif

    myLotL=LotSizeL

     

    ///////////////////// for SHORT trades

    once LotSizeS = 1

    Once MinSizeS = 1      //minimum size required

    Once LotSizeS = MinSizeS  //starting size (can be bigger than minimum)

    Once LotStepS = LS200 //250      //increase/decrease this money step

    LotSizeS = max(MinSizeS,round((MinSizeS/MS),1) + (MinSizeS * round((ShortProfit / LotStepS),1)))

    if LotSizeS>MU then

    LotSizeS=MU-MMUU   //MU e MMUU metterli con decimale 0.5

    endif

    myLotS=LotSizeS

    //////////////////////////////////// END

     

    Io adesso ho provato a farlo in questo modo ma non mi apre alcuna posizione:

    ONCE LongP = 0
    ONCE ShortP = 0
    once myLot=0.5
    IF StrategyProfit <> StrategyProfit[1] AND BarIndex > 0 THEN
    Profitto = StrategyProfit – StrategyProfit[1]
    IF LongOnMarket[1] THEN
    LongP = LongP + Profitto
    ELSIF ShortOnMarket[1] THEN
    ShortP = ShortP + Profitto
    ENDIF
    endif

    if LongP > LongP[1] and LongP => LL200 then
    myLotL = (myLotL + round((MS)*FXLL))
    endif
    if LongP < LongP[1] and LongP <= LL200 and myLotL > MS then
    myLotL = (myLotL – round((MS)*FXLS))
    endif

    if ShortP > ShortP[1] and ShortP => LS200 then
    myLotS = (myLotS + round((MS)*FXSL))
    endif
    if ShortP < ShortP[1] and ShortP <= LS200 and myLotS > MS then
    myLotS = (myLotS – round((MS)*FXSS))
    endif

    GRAZIE PER L’AIUTO !!!!!

    #202301 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ho provato, ma mancano alcune variabili.

    Posta il file ITF.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Roberto HELP, profit e q.tà contratti


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
MaoRai54 @maorai Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
3 years, 11 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/06/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...