Conversion of Tiki Scalper indicator from NinjaTrader

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

    Hi everyone,

    Wondered if anyone would be able to help convert this NinjaTrader code for an indicator into Prorealcode?

    const predef = require('./tools/predef')
    
    class tikiScalper {
        init() {
            this.isBuy = true
        }
    
        map(d, i, history) {
            if (i < 5) {
                return
            }
            
            const close = d.close()
            const priorClose = history.get(i - 1).close()
            const priorPriorClose = history.get(i - 2).close()
            const priorPriorPriorClose = history.get(i - 3).close()
            
            const isBuy = priorClose < close && 
                (priorPriorClose < priorClose ||
                priorPriorPriorClose < priorClose) 
            
            const isSell = priorClose > close && 
                (priorPriorClose > priorClose ||
                priorPriorPriorClose > priorClose) 
                
            if (isBuy) {
                this.isBuy = true 
            } else if (isSell) {
                this.isBuy = false
            }
            
            const {
                upColor,
                downColor
            } = this.props
            
            const color = this.isBuy ? upColor: downColor
            
            return {
                candlestick: {
                  color
                }
            }
        }
    }
    
    module.exports = {
        name: 'tikiScalper',
        description: 'Tiki Scalper',
        calculator: tikiScalper,
        params: {
            upColor: predef.paramSpecs.color('lime'),
            downColor: predef.paramSpecs.color('red'),
        },
        tags: ['Tiki Tools']
    }

    Many thanks,

    Jim

    #230362 quote
    JSJS
    Participant
    Master

    Hi,

    Hereby the conversion:

    Once isBuy=1
    
    If BarIndex>5 then
    PClose=Close[1]
    PPClose=Close[2]
    PPPClose=Close[3]
    
    isBuy=(PClose<Close) and ((PPClose<PClose) or (PPPClose<PClose))
    isSell=(PClose>Close) and ((PPClose>PClose) or (PPPClose>PClose))
    EndIf
    
    If isBuy then
    isBuy=1
    ElsIf isSell then
    isBuy=0
    EndIf
    
    If isBuy=1 then
    DrawCandle(Open,High,Low,Close)Coloured("Lime")
    Else
    DrawCandle(Open,High,Low,Close)Coloured("Red")
    EndIf
    
    Return
    
    neddyboy thanked this post
    Scherm­afbeelding-2024-03-24-om-16.54.42.png Scherm­afbeelding-2024-03-24-om-16.54.42.png
    #230394 quote
    neddyboyneddyboy
    Participant
    New

    Thanks for your help, that’s great.

    JS thanked this post
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

Conversion of Tiki Scalper indicator from NinjaTrader


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
neddyboy @neddyboy Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/24/2024
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...