Aiuto Creazione sistema di Scalping

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #86190 quote
    Gianluca
    Participant
    Master

    Buongiorno, sto cercando di codificare un sistema di scalping che entri ad un prezzo limit pari al massimo della barra precedente se si sono verificate determinate condizioni, vorrei che lo stop sia il minimo della barra che ha determinato la condizione di entrata (in questo caso la precedente) poi vorrei che il sistema aggiorni lo stop con il minimo di ogni barra che segna nuovi massimi. ho provato a codificare qualcosa, ma il sistema non entra al prezzo giusto. Allego il codice ed anche una foto. @Robertogozzi @Nicolas se avete 10 minuti potreste aiutarmi?

    DEFPARAM CUMULATEORDERS=FALSE
    DEFPARAM PRELOADBARS = 1000
    ema15 = exponentialaverage[15]
    chanup = average[40](high)
    //chandn = average[40](low)
    timeon= time > 080000 and time < 220000
    
    
    
    
    once signal=0
    
    bull = ema15>chanup and summation[5](ema15>ema15[1])=5
    if bull then
    nuoviminimi    = 1
    signal=1
    endif
    IF nuoviminimi THEN
    IF nuoviminimi = 0 THEN
    nuoviminimi = low < low[1]
    ENDIF
    endif
    if signal>0 then
    if nuoviminimi then
    entrata=high[1]+1*pipsize
    sl= high-low
    graphonprice entrata
    graph sl
    Cond = nuoviminimi
    if Cond and timeon and Not OnMarket then
    buy 1 contract at entrata limit 
    set stop ploss sl
    signal=0
    nuoviminimi=0
    endif
    endif
    endif
    
    if onmarket then
    newsl=low[1]
    if newsl>low[1] then 
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    endif
    Cattura.jpg Cattura.jpg
    #86226 quote
    Nicolas
    Keymaster
    Master

    Il problema è che aggiorni la “newsl” variabile con lo stesso valore che la stai confrontando, direttamente alla riga successiva! è per questo che il tuo stop loss non viene mai aggiornato! (righe 40 e 41)

    #86250 quote
    Gianluca
    Participant
    Master

    newsl

    OH GRAZIE! ed invece come mai il prezzo di entrata non viene rispettato?

    #86390 quote
    Nicolas
    Keymaster
    Master

    Per un ordine di acquisto, il prezzo limite per l’ordine in sospeso deve essere inferiore. Dovresti essere sicuro che è il caso altrimenti l’ordine verrà lanciato direttamente sul mercato. Penso che questo sia il motivo per cui pensi che il prezzo di entrata non rispetti i tuoi calcoli.

    #86398 quote
    Gianluca
    Participant
    Master

    ho verificato ce la barra apre sotto il prezzo che io voglio, avevo pensato a questo problema, ma ho verificato più volte che non è questo il caso.

    #86404 quote
    Nicolas
    Keymaster
    Master

    Se si desidera acquistare sopra, è necessario utilizzare gli ordini STOP, se si desidera acquistare sotto utilizzare ordini LIMIT:

    [attachment file=86405]

    [attachment file=86407]

    limit-orders.png limit-orders.png stop-orders.png stop-orders.png
    #86427 quote
    Gianluca
    Participant
    Master

    che ingenuo che sono, scusatemi e grazie.

    #88615 quote
    Gianluca
    Participant
    Master

    Scusatemi, una info, se volessi che lo stop sia fisso, e cioè il minimo della barra che ha fatto scattare il segnale di entrata come dovrei codificarlo?

    #88628 quote
    robertogozzi
    Moderator
    Master

    Cambia la riga 26:

    sl = (entrata - low) / pipsize
    #116334 quote
    Gianluca
    Participant
    Master
    IF NOT ONMARKET THEN
    newsl=0
    ENDIF
    CandleSl=10
    numberCandles = (BarIndex - TradeIndex)
    if onmarket then
    if low>low[1] and numberCandles>=CandleSl then
    newsl=low[v1]
    GRAPHONPRICE NEWSL
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    endif

    Così va bene? ho messo che dopo 10 candele lo sl diventa ogni minimo

    #116335 quote
    robertogozzi
    Moderator
    Master

    Non ho capito cosa sia V1 alla riga 8.

    La logica del codice dovrebbe essere:

    IF NOT ONMARKET THEN
       newsl=0
    ENDIF
    CandleSl=10
    numberCandles = (BarIndex - TradeIndex)
    if onmarket then
       if low>low[1] and numberCandles>=CandleSl then
          newsl=low[v1]
       endif
    ENDIF
    If NewSL > 0 THEN
       SELL AT newSL STOP
       EXITSHORT AT newSL STOP
    ENDIF
    GRAPHONPRICE NEWSL
    #116401 quote
    Gianluca
    Participant
    Master
    IF NOT ONMARKET THEN
       newsl=0
    ENDIF
    CandleSl=10
    numberCandles = (BarIndex - TradeIndex)
    if onmarket then
       if low>low[1] and numberCandles>=CandleSl then
          newsl=low[1]
       endif
    ENDIF
    If NewSL > 0 THEN
       SELL AT newSL STOP
       EXITSHORT AT newSL STOP
    ENDIF
    GRAPHONPRICE NEWSL

     

    Scusa avevo dimenticato di togliere la variabile l’ho riscritto.

    Mi puoi spiegare la logica di If NewSL > 0 THEN ??

    #116405 quote
    robertogozzi
    Moderator
    Master

    Serve per uscire solo se almeno una volta la linea 8 è stata eseguita.

    #116411 quote
    Gianluca
    Participant
    Master

    ok grazie

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

Aiuto Creazione sistema di Scalping


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Gianluca @altares Participant
Summary

This topic contains 13 replies,
has 3 voices, and was last updated by Gianluca
6 years, 1 month ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 12/02/2018
Status: Active
Attachments: 3 files
Logo Logo
Loading...