Finding highest and lowest EMA

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #132913 quote
    lqianhlqianh
    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
    robertogozzirobertogozzi
    Moderator
    Legend

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

    #132917 quote
    lqianhlqianh
    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
    VonasiVonasi
    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
    GraHalGraHal
    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.
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

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 GraHalGraHal
6 years, 4 months ago.

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