Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting alert in Ninjascript.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Setting alert in Ninjascript.

    Hello

    There is whell known possibility to set an allert with various actions (sound alarm, pop-up message, order placement) in the event linked with a drawing object - e.g. cross up/down the line.. enter/exit of the box area.

    Is it possible to do the same from the script.
    For example I daw the line in the script and arm an alert to that line right in the script.
    Would it be possible?

    I found there is an Alert() function which call an alert action itself.. but there is no anything like alert condition definition
    Is it expected that I have to implement an alert logic in the cript myself, eg control that price crossover the line I drew in the script ?



    thanks

    Andrei

    #2
    Hi Andrei, thanks for writing in. With a script, your script conditions are the alert conditions e.g.

    if (CrossAbove(CCI(14), 250, 1))
    {
    Alert(...);
    }

    You can use the Strategy builder to generate Strategy code and use Alerts and Drawing tools in the Actions menu for a similar experience:

    Comment


      #3
      Hello Chris

      yeh.. the method is obvious. Just I was looking form some way to attach an Alert to a Drawing object.
      You see, I am trying to implement the lIndicator ogic when I put multiple drawing marks (on some condition) on charts and remove them as soon as the price approaced them (cross their level). In some scenarious there could be hundreds of such marks.. and looks like I have no choice but make a cycled matching of the current price level with the draw object Anchor price. I do thi now, but the problem is that after any change on the charts (e.g timeframe) it cause sencitive delay for initial Indicator calculation before the charts what to work normally.

      I though there some built-in alert process which can be linked with a drawing. Similar as when I create drawing manually on charts I can create an Alert linked to this drawing.

      Thanks anyway.. I'll work on the script code optimisation to improve its performace.

      BR

      Andrei

      Comment


        #4
        Hi Andrei, you might want to look at the Dictionary or KeyValuePair data structure. This usually has the fastest look up time of any data structure:

        https://docs.microsoft.com/en-us/dot...2?view=net-6.0 (publicly available)

        Comment


          #5
          Right.. I was looking into this.. just in my case it doesnt give much prefference agains e.g simple ArrayList. as I am not searching as partitular value in the key.. but matching each of the list element to be higher or lower than current price..

          btw.. may you advice how to make it more efficent as I do match during the onBarUpdate and if to draw the mark on the bar close is pretty good.. but for remove the mark is better in real time with price change. I have tried to use onMarketData with price change status.. but it wont work because of some reason.

          Comment


            #6
            Hi Hi Andrei, when you draw the object, you can make a unique ID for the Key and the DrawObject name as the value. This would be the most efficient lookup method. It really depends on exactly what you are doing in the code. Also see GUID to make unique IDs:
            https://docs.microsoft.com/en-us/dot...d?view=net-6.0 (publicly available)

            Comment


              #7
              Thanks Chris

              I have simplified the logic aand it does not required look up at all.. I simply match with the most recent object drawn .. no cycles at all and this is run like a charm

              thanks again

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              574 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              333 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X