Finding highest and lowest EMA

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #132913 quote
    lqianh
    Participant
    Junior

    Hi brains, I want to find the highest and lowest EMA between my current barindex to the previous tradeindex, but the following simple code returns nothing.

    Please advise what I have done wrong? Much appreciated.

    EMA=exponentialaverage[10](close)
    HH=highest[barindex-tradeindex](EMA)
    LL=lowest[barindex-tradeindex](EMA)
    
    return HH as "HighestEMA", LL as "LowestEMA"
    #132915 quote
    robertogozzi
    Moderator
    Master

    TRADEINDEX is to be used in a strategy, not in an indicator.

    #132917 quote
    lqianh
    Participant
    Junior

    Yes, actually, I am using in a strategy, trying to debug.

    In my code, I actually used

    graph HH as “HighestEMA”

    Nothing came out.

    Thanks.

    #132918 quote
    Vonasi
    Moderator
    Master

    Sometimes it is necessary to make sure you have enough bars before starting to calculate or nothing gets displayed. Try this:

    if barindex >= 10 and tradeindex <> 0 then
    EMA=exponentialaverage[10](close)
    HH=highest[barindex-tradeindex](EMA)
    LL=lowest[barindex-tradeindex](EMA)
    endif
    
    graph HH as "HighestEMA"
    graph LL as "LowestEMA"
    #132921 quote
    GraHal
    Participant
    Master

    Above added as Log 215 here

    Snippet Link Library

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

Finding highest and lowest EMA


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
lqianh @lqianh Participant
Summary

This topic contains 4 replies,
has 4 voices, and was last updated by GraHal
5 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/23/2020
Status: Active
Attachments: No files
Logo Logo
Loading...