Variable and Operator

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9935 quote
    PaulmelbPaulmelb
    Participant
    New

    Hi,

     

    Is it possible to use a variable to return an operator (or also a string).  Example of part of code below:

    IF opVar = 1 THEN
    myOperator = > 
    ELSIF opVar = 2 THEN
    myOperator = <
    
    ENDIF

    For this opVAR would be a variable set in ‘Variable optimization’ and myOperator could be used elsewhere in the code where I wanted to check different results based on less than or greater than.

    Thanks

    #9941 quote
    grizzlygrizzly
    Participant
    Average

    Hi Paul
    Great question – math operators can’t be used as variables.

    You could try and code the conditions to +1 or -1 from the myoperator variable based on prior conditions and take it from there. If that makes sense.

    Cheers

    Nicolas thanked this post
    #9980 quote
    PaulmelbPaulmelb
    Participant
    New

    Thanks grizzly… yep, will rewrite code and use conditions as you mentioned.

Viewing 3 posts - 1 through 3 (of 3 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

Variable and Operator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Paulmelb @paulmelb Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by PaulmelbPaulmelb
10 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/28/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...