Code Generating incorrect entry point

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #232614 quote
    pdrh
    Participant
    Average

    I have an indicator which I copied from the Forums which generates a long entry signal

    a=MACD[12,26,9](close)
    if (a crosses under 0) then
    basso=low
    barrabasso=barindex
    endif
    if a<0 then
    if low<basso then
    basso=low
    barrabasso=barindex
    endif
    endif
    if a crosses over 0 then
    DRAWARROWUP(barrabasso, basso-1)coloured(255,255,255)
    endif
    return

    So I thought I could use this in an Algo as below

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    a=MACD[12,26,9](close) 
    if (a crosses under 0) then
    basso=low
    barrabasso=barindex
    endif
    if a<0 then
    if low<basso then
    basso=low
    barrabasso=barindex
    endif
    endif
    LNG=a crosses over 0
    if LNG and not longonmarket then
    buy 3 contracts at market
    endif
    set Stop Ploss SL
    set target pprofit TP
    graph LNG

    The algo generates an entry signal which is later than the indicator signal even though the code for the 2 is the same .

    Help please

    Screenshot-2024-05-14-162840.jpg Screenshot-2024-05-14-162840.jpg
    #232616 quote
    PeterSt
    Participant
    Master

    An obvious reason would be that the Indicator generates “in bar” an Entry arrow (works at Tick level), which is not valid any more at the transition to the next bar with the longer timeframe (like 1 hour).

    Could that be the situation at hand ?

    #232618 quote
    JS
    Participant
    Senior

    The indicator is “repainting”…

    When drawing the “DrawArrowUP”, the indicator uses a bar index (barrabasso) and a value (basso) that do not come from the “MACD crosses under” but from the “Low” values…

    This is where it goes wrong, the “Arrow” doesn’t use the values of the “Crosses Under” but of the “Low” value…

    If Low<basso then

    basso=low

    barrabasso=barindex

    EndIf

    If you don’t use this piece of code, you will get the same signals…

    pdrh thanked this post
    #232646 quote
    pdrh
    Participant
    Average
      Yes it is repainting. Takes my 88 year old brain a while to see these things sometimes.!
    JS thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Code Generating incorrect entry point


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
pdrh @pdrh Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by pdrh
1 year, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/14/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...