Split posizione e TrP a breakeven

Viewing 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • #178288 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Certo, perché non hai messo le condizioni per entrare LONG o SHORT, quindi esegue entrambe, ma siccome l’entrata SHORT è successiva, automaticamente quella LOBG viene cancellata.
    Se le inverti vedrai che entrerà sempre LONG.

    #178289 quote
    MauroProMauroPro
    Participant
    Veteran

    Come devo modificare il codice per entrare sia long che short anche “at market”?

    #178296 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Vanno indicate le condizioni per entrare LONG e quelle per entrare SHORT (qundo entri a mercato, le altre volte piazzi sempre due ordini pendenti):

    if cTime and dayOfWeek <>5 and Not OnMarket then
       if (time = endTime) then
          IF MyLongConditions THEN
             buy positionSize contracts at market
          ELSIF MyShortConditions THEN
             sellShort positionSize contracts at market
          ENDIF
       else
          buy positionSize contracts at chiusura – range2H*ratio limit
          sellshort positionSize contract at chiusura + range2H*ratio limit
       endif
    endif
    #178301 quote
    MauroProMauroPro
    Participant
    Veteran

    Mi sono espresso male, le condizioni di entrata sono già negli ordini pendenti.

    Vorrei solo aggiungere questa ulteriore entrata: nel caso gli ordini pendenti non fossero presi e time = endTime, allora entra long at market se il close è inferiore a CHIUSURA e short se è superiore.

    Ho provato a scrivere questo codice. ma ancora non funziona (non prende nessun ordine at market) e non capisco il motivo.

    if time = startTime then
    range2H = highest[Period](high) - lowest[Period](low)  
    chiusura = close     
    endif
    
    if cTime and dayOfWeek <>5 then
    buy positionSize contracts at chiusura - range2H*ratio limit
    else
    if (time = endTime) and close < chiusura and not onMarket then
    buy positionSize contracts at market
    endif
    endif
    
    if cTime and dayOfWeek <>5 then
    sellshort positionSize contract at chiusura + range2H*ratio limit
    else
    if (time = endTime) and close > chiusura and not onMarket then
    sellShort positionSize contracts at market
    endif
    endif
    #178312 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Bastava che dove ho indicato le condizioni tu ci mettessi le tue, MyLongConditions e MyShortConditions non esistono, servono solo per indicarti dove mettere le tue.

    Le righe 6 e 14 le esegue agli orari stabiliti dal Lunedì al Giovedì.

    Le righe 9 e 17 le esegue SOLO il Venerdì all’ora ultima.

    Questo è il codice che ho postato prima con le tue condizioni che hai detto:

    if cTime and dayOfWeek <>5 and Not OnMarket then
       if (time = endTime) then
          IF close < chiusura THEN
             buy positionSize contracts at market
          ELSIF close > chiusura THEN
             sellShort positionSize contracts at market
          ENDIF
       else
          buy positionSize contracts at chiusura – range2H*ratio limit
          sellshort positionSize contract at chiusura + range2H*ratio limit
       endif
    endif

    Può entrare da Lunedì a Giovedì tra le 210000 e le 231500 con ordini pendenti, tranne l’ultima candela, quella delle 231500 in cui entra a mercato secondo le condizioni che mi hai indicato nell’ultimo post.

    MauroPro thanked this post
    #178320 quote
    MauroProMauroPro
    Participant
    Veteran

    Funziona (non capisco però dove è l’errore nel mio codice sopra, mi sembra cambiata solo l’inversione dell’ordine pendente con quello at market).

Viewing 6 posts - 16 through 21 (of 21 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

Split posizione e TrP a breakeven


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
MauroPro @mauropro Participant
Summary

This topic contains 20 replies,
has 2 voices, and was last updated by MauroProMauroPro
4 years, 12 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 09/15/2021
Status: Active
Attachments: 5 files
ProRealCode ProRealCode
Loading...